package com.bbznb.config;

import com.bbznb.entity.MyOrder;
import com.bbznb.service.UserService;
import com.bbznb.util.OrderQueryDTO;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserTool {
    @Autowired
    private UserService userService;
    @Tool("购买电影票")
    public void Buy(
            @P("电影名称") String username
    )
    {
        userService.BuyTickets(username);
    }
    @Tool("获取订单信息")
    public List<MyOrder> getOrders(
            @P("订单状态") String status,
            @P("电影名称") String name

    )
    {
        OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
        Integer data = 1;
        if(status.contains("已支付")){
            data = 1;
        }
        else if(status.contains("未支付")){
            data = 0;
        }
        orderQueryDTO.setStatus(data);
        if(name!= null){
        orderQueryDTO.setKeyword(name);}
        return  userService.getOrders(orderQueryDTO);
    }


}
